﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Communergy.Common;

namespace Communergy.Repository.InMemory.Tests
{
    public class InMemoryTestHelpers
    {
        public const string METER_NAME = "Meter";
        public const string METER_ID = "36ABB12E-BB2A-41F9-9244-B8C15C4BBE36";

        public const string METER_SOURCE_NAME = "MeterSource";
        public const string METER_SOURCE_ID = "25703586-f2c9-4f21-a71d-5107352d35e2";

        public static DateTime START_DATE = new DateTime(2010, 1, 1);

        public static Meter GetTestMeter()
        {
            return new Meter 
            { 
                MeterId = METER_ID,
                MeterName = METER_NAME 
            };
        }

        internal static MeterSource GetTestSource()
        {
            return new MeterSource
            {
                Name = METER_SOURCE_NAME,
                Id = METER_SOURCE_ID
            };
        }

        public static Meter GetTestMeterWithSource()
        {
            var meter = GetTestMeter();
            var source = GetTestSource();
            meter.Sources.Add(source);
            return meter;
        }


        internal static List<EnergyData> SimpleEnergyDataList()
        {
            List<EnergyData> simpleEnergyDataList = new List<EnergyData>();
            EnergyData energyData = new EnergyData
            {
                AverageWatts = 100,
                Interval = new TimeSpan(0,0,6),
                ReadingDateTime = DateTime.Now
            };
            simpleEnergyDataList.Add(energyData);
            return simpleEnergyDataList;
        }

        internal static List<EnergyData> MultipleEnergyDataItems(DateTime startDate, TimeSpan interval, int items, decimal watts)
        {
            var dataItems = new List<EnergyData>();
            DateTime readingDateTime = startDate;
            for (int i = 0; i < items; i++)
            {
                var energyDataItem = new EnergyData();
                energyDataItem.ReadingDateTime = readingDateTime;
                energyDataItem.AverageWatts = watts;
                energyDataItem.Interval = interval;
                dataItems.Add(energyDataItem);

                readingDateTime = readingDateTime.Add(interval);
            }
            return dataItems;
        }

        
    }
}
